//
//  VistorView.swift
//  WeiboProject
//
//  Created by amos on 16/1/18.
//  Copyright © 2016年 itheima. All rights reserved.
//

import UIKit

class VistorView: UIView {
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        //1.设置颜色
        backgroundColor = UIColor.whiteColor()  
    }

    override func layoutSubviews() {
        super.layoutSubviews()
        
         //1.设置背景图片
        let homeIcon:UIImageView = UIImageView(image: UIImage(named: "visitordiscover_feed_image_house"))
        
        //1.2
        homeIcon.sizeToFit()
        
        //1.3
        addSubview(homeIcon)
        
       
        //1.4设置约束
        homeIcon.translatesAutoresizingMaskIntoConstraints = false
      
        addConstraint( NSLayoutConstraint(item: homeIcon, attribute: .CenterX, relatedBy: .Equal, toItem: self, attribute: .CenterX, multiplier: 1, constant: 0))
        
        addConstraint( NSLayoutConstraint(item: homeIcon, attribute: .CenterY, relatedBy: .Equal, toItem: self, attribute: .CenterY, multiplier: 1, constant: 0))
        
        //2.设置圆环
        
        //1.设置背景图片
        let cicrlIcon:UIImageView = UIImageView(image: UIImage(named: "visitordiscover_feed_image_smallicon"))
        
        //1.2
        cicrlIcon.sizeToFit()
        
        //1.3
        addSubview(cicrlIcon)
        
        
        //1.4设置约束
        cicrlIcon.translatesAutoresizingMaskIntoConstraints = false
        
        addConstraint( NSLayoutConstraint(item: cicrlIcon, attribute: .CenterX, relatedBy: .Equal, toItem: self, attribute: .CenterX, multiplier: 1, constant: 0))
        
        addConstraint( NSLayoutConstraint(item: cicrlIcon, attribute: .CenterY, relatedBy: .Equal, toItem: self, attribute: .CenterY, multiplier: 1, constant: 0))
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
